<?php
namespace app\adminapi\controller;

use app\adminapi\logic\LoginLogic;
use app\adminapi\service\tools\BuildLangService;
use app\adminapi\validate\LoginValidate;

use app\common\enum\LangEnum;
use app\common\model\lang\LangTranslate;
use app\adminapi\logic\setting\lang\LangLogic;

/**
 * 管理员登录控制器
 * Class LoginController
 * @package app\adminapi\controller
 */
class LoginController extends BaseAdminApiController
{
    public $notNeedLogin = ['account'];

    /**
     * @notes 账号登录
     * @return \support\Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function account()
    {
        $params = (new LoginValidate())->post()->goCheck();
        return $this->data((new LoginLogic())->login($params));
    }

    /**
     * @notes 退出登录
     * @return \support\Response
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function logout()
    {
        //退出登录情况特殊，只有成功的情况，也不需要token验证
        (new LoginLogic())->logout($this->adminInfo);
        return $this->success();
    }
}